import plotly.graph_objs as gomeasure_col_name ="Data_Value"state_avg = data.groupby("StateAbbr")[measure_col_name].mean().reset_index()overall_avg = state_avg[measure_col_name].mean()max_state = state_avg.loc[state_avg['Data_Value'].idxmax()]#show the detailsstate_avg.head(), overall_avg, max_state#fig for usfig = go.Figure()fig.add_trace(go.Bar( x=state_avg["StateAbbr"], y=state_avg["Data_Value"], name="%", marker_color="skyblue"))fig.add_trace(go.Scatter( x=state_avg["StateAbbr"], y=[overall_avg] *len(state_avg), name="Average", line=dict(color="gray", width=2, dash="dash")))fig.add_annotation( x=max_state['StateAbbr'], y=max_state['Data_Value'], text=f"State: {max_state['StateAbbr']}<br>Average: {max_state['Data_Value']:.2f} %", showarrow=True, arrowhead=1)fig.update_layout( title={'text': 'Avg. Health Insurance Coverage by States','y':0.9,'x':0.5,'xanchor': 'center','yanchor': 'top'}, xaxis_title="State", yaxis_title="Avg. Health Insutance Cover (%)", showlegend=False)fig.show()
Figure 2: Average Health Insurance Coverage By Satates in US
Interactive plot for the average percentage of health insurance coverage across various US states shows that Texas stands out with the highest coverage rate—almost 28%, well above the national average. The dashed horizontal line across the chart suggests the overall average health insurance coverage, allowing for a quick visual comparison between each state’s coverage and the overall average. This kind of info can really help us see where things are going well and where there’s room for improvement in making sure everyone has access to health care.
Marketplace Premium Data in US
Code
import pandas as pdimport numpy as npimport plotly.graph_objects as go#import dataenrollment_df = pd.read_csv('../data/kff_enrollment.csv')metal_tier_df = pd.read_csv('../data/cleaned_kff.csv')issuers_df = pd.read_csv('../data/issuers.csv')#retain only the following colsissuers_df = issuers_df[['Location', 'Number of Issuers in 2024']]#merge dfsmerged_df = pd.merge(enrollment_df, metal_tier_df, on='Location')merged_df = pd.merge(merged_df, issuers_df, on='Location')merged_df = merged_df.drop('Average Benchmark Premium', axis=1)merged_df = merged_df.drop(index=0)#calculate avg premium and rank based on premium avg (1 is lowest and 50 is highest)merged_df['Average Premium'] = merged_df[['Average Lowest-Cost Bronze Premium', 'Average Lowest-Cost Silver Premium', 'Average Lowest-Cost Gold Premium']].mean(axis=1)merged_df['Average Premium'] = merged_df['Average Premium'].round(2)merged_df['Overall Rank'] = merged_df['Average Premium'].rank(method='min', ascending=True)#choose color scaleheader_color ='teal'col_even_color ='lightgreen'col_odd_color ='white'#create tabletable_fig = go.Figure(data=[go.Table( header=dict( values=list(merged_df.columns), line_color='black', fill_color=header_color, align='center', font=dict(color='white', size=12) ), cells=dict( values=[merged_df[col] for col in merged_df.columns], line_color='black', fill_color=[col_odd_color if i %2==0else col_even_color for i inrange(len(merged_df))], align='center', font=dict(color='black', size=11) ))])table_fig.update_layout( title='Marketplace Premium Data by State, 2024', margin={'t': 50} )table_fig.show()
Figure 3: Marketplace Premium Data by US State in 2024
This table summarizes marketplace insurance enrollment by rank and tier in 2024 across all 50 states. Marketplace insurance is defined as health insurance coverage available through the Health Insurance Marketplace through The Affordable Care Act. It is intended to assist families and individuals in attaining affordable healthcare. The table also contains data on the number of marketplace insurance issuers per state, as well as the calculated average premium for each state. Then, we ranked the states in ascending order, meaning the state with the lowest average premium is rank #1 and the state with the highest average premium is rank #50. The marketplace data indicates that West Virginia has the highest premium and Maryland has the lowest average.